function ajax(options) {
	var xhr = null;
	// var baseURL='https://campus.zpparking.com/api/';
	var baseURL='/api/';
	options.url=baseURL+options.url;
	
	//创建对象
	if(window.XMLHttpRequest) {
		xhr = new XMLHttpRequest()
	} else {
		xhr = new ActiveXObject("Microsoft.XMLHTTP"); //>IE8
	}
	

	// 连接
	if(options.type == "GET") {
		var params = formsParams(options.data);
		xhr.open(options.type, options.url + "?" + params, options.async);
		if(sessionStorage.getItem('token')) {
			var token = 'Bearer ' + sessionStorage.getItem('token'); //带上token
			xhr.setRequestHeader("Authorization", token);
		}
		xhr.send(null)
	} else if(options.type == "POST") {
		xhr.open(options.type, options.url, options.async);
		if(sessionStorage.getItem('token')) {
			var token = 'Bearer ' + sessionStorage.getItem('token');
			xhr.setRequestHeader("Authorization", token);
		}
		xhr.setRequestHeader("Content-Type", "x-www-form-urlencoded");
		xhr.send(options.data);
	}

	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && xhr.status == 200) {
			var data = JSON.parse(xhr.response);
			options.success(data);
		}
	}

	//拼接“get”方法参数
	function formsParams(data) {
		var arr = [];
		for(var prop in data) {
			arr.push(prop + "=" + data[prop]);
		}
		return arr.join("&");
	}

}